package com.lankystar.sos.service.impl;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.lankystar.sos.dao.IUserDao;
import com.lankystar.sos.dao.IUserLocationDao;
import com.lankystar.sos.model.User;
import com.lankystar.sos.model.UserLocation;
import com.lankystar.sos.service.IAddDataInterface;

@Service
@Transactional
public class AddDataInterface implements IAddDataInterface{

	@Autowired
	private IUserDao userDao;
	@Autowired
	private IUserLocationDao locationDao;
	@Override
	public void addListUser(Double longitude, Double latitude) {
		for (int i = 0; i < 10; i++) {
			
			User user = new User();
			user.setUserPhone("1234567890"+i);
			user.setUserPassword("123456");
			user.setUserGender("0");
			userDao.addUser(user);
			UserLocation location = new UserLocation();
			location.setLastUpdateTime(new Date());
			location.setLatitude(latitude+i+i*(0.5));
			location.setLongitude(longitude+i+i*(0.5));
			location.setUser(user);
			locationDao.addUserLocation(location);
		}
		
	}

}
